package com.njbdqn.util

import java.io.FileInputStream
import java.util.Properties

object ReadPropertiesFileTool {
  def readProperty(flag:String)={
    val prop = new Properties()
    // getClassLoader 是 scala 中区别于Java的地方，object是Java类的封装
    prop.load(new FileInputStream(ReadPropertiesFileTool.getClass.getClassLoader.getResource("driver.properties").getPath))
    var map = Map[String,String]().empty
    if (flag.equalsIgnoreCase("mysql")){
      map += ("driver"->prop.getProperty("driver"))
      map += ("url"->prop.getProperty("url"))
      map += ("user"->prop.getProperty("user"))
      map += ("password"->prop.getProperty("password"))
    }else{
      map += ("hadoop_url"->prop.getProperty("hadoop_url"))
    }
    map
  }
}
